<template>
  <!-- 新增企业 表单 -->
  <a-modal
    v-model:open="visible"
    :title="确认告警"
    class="addRule"
    destroyOnClose
    :width="520"
    @cancel="cancel"
    centered
  >
    <a-form
      :model="confirmForm"
      layout="inline"
      :labelCol="labelCol"
      ref="formRef"
    >
      <a-form-item label="确认内容：" :rules="[{ required: true }]">
        <a-textarea
          v-model:value="confirmForm.message"
          class="formInput"
          placeholder="请输入"
          allow-clear
          style="height: 100px"
        />
      </a-form-item>
    </a-form>

    <template #footer>
      <div class="footerBar">
        <a-button key="back" @click="cancel">取消</a-button>
        <a-button
          key="submit"
          type="primary"
          :loading="loading"
          @click="handleSubmit"
          >确认</a-button
        >
      </div>
    </template>
  </a-modal>
</template>
<script setup>
import {
  COMMUNICATION_ALARMS,
  EFFECT_TIME_LIST,
  IS_AUTO_WORK_ORDER_LIST,
  JUDGE_CONDITION_LIST,
  KEEP_MINUTE_LIST,
  RULE_STATUS_LIST,
  RULE_TYPE_LIST,
  SECURITY_ALARMS,
  SILENT_MINUTE_LIST,
  WARN_EQUIP_LEVEL_LIST,
  WARN_LEVEL_LIST,
  WARN_STATUS_NAME,
} from "@/constants/stationConfig.js"

const $api = inject("$api")
const props = defineProps({
  confirmWarnVisible: {
    type: Boolean,
    default: false,
  },
  rowData: {
    type: Object,
  },
  isEdit: {
    type: Boolean,
    default: false,
  },
  id: {
    type: Number,
    default: 0,
  },
})
const loading = ref(false)
const visible = ref(props.confirmWarnVisible)

const emits = defineEmits([
  "update:confirmWarnVisible",
  "update:getWarnInfoList",
])
watch(
  () => props.confirmWarnVisible,
  (val) => {
    console.log(val)
    visible.value = val
  }
)
const confirmForm = ref({
  id: null,
  message: null,
})
watch(
  () => props.id,
  (val) => {
    confirmForm.value.id = val
  },
  { immediate: true }
)
const labelCol = { style: { width: "100px" } }
const formRef = ref(null)

const cancel = () => {
  emits("update:confirmWarnVisible", false)
  confirmForm.value.id = null
  confirmForm.value.message = null
}

const handleSubmit = async () => {
  /* const params = {
    id: confirmForm.value.id,
    message: confirmForm.value.message,
  }; */

  const res = await $api.warnConfirm(confirmForm.value)
  loading.value = false
  if (res.code === 0) {
    message.success("确认成功")
    emits("update:getWarnInfoList")
    cancel()
  }
}

const ruleNameOptions = ref([])
</script>

<style lang="less" scoped>
.form {
  padding: 0 40px;
  margin-top: 30px;
}
.formInput,
.formSelect {
  width: 350px;
}
.ant-form-item {
  margin-top: 20px;
}
.footerBar {
  text-align: center;
  margin-top: 30px;
}
.areaSelectContent {
  display: inline-block;
}
.areaSelectContent {
  display: inline-block;
}
.areaSelect {
  display: inline-block;
  width: 113px;
  margin-right: 5px;
  &:last-child {
    margin-right: 0;
  }
}
</style>
